

/* simple password protection using a cookie */

/* below is the script to be placed in a redirecting page to enter the password
place it in the header of the target page*/



function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkCookie()
{
var buckeyeboards=getCookie("buckeyeboards");/* name for cookie (replace all) */

if (buckeyeboards!=null && buckeyeboards!="")
  {window.location.href="index.html";  /* change to target/index page of protected area */

  }
  else
  {
 
passWord()}

function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password For the Members Area','');/* first prompt for password */

while (testV < 3) {/* change "3" to number of atempts to get the password.  must be changed below too */
if (pass1==null || pass1=="") {
window.location.href="index.html";}/* target page if password fails */

if (pass1.toLowerCase() == "pepper") {/* change to desired password */

setCookie("buckeyeboards",buckeyeboards,365);/* 365 is the number of days the cookie is valid for */

window.location.href="members.html";
break;
}

testV+=1;
var pass1 = 
prompt('Last Try!','');/* second prompt for password */

}
if (pass1.toLowerCase()!="password" & testV ==3) /* change "3" to number of atempts to get the password.  must be changed above too */
alert('Now Redirecting To Buckeye Charter School Boards Home Page')
window.location.href="index.html"; /* target page if password fails */
return "";

}
} 

/* script for cookie below 
put from this point down into the head of any page that needs to be protected by the password.  
*/
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkCookie()
{
var buckeyeboards=getCookie("buckeyeboards");
if (buckeyeboards!=null && buckeyeboards!=""){}
  else
  {
 window.location.href="login.html";
 }
 }
/* 
in head: <script src="password.js"/>
body tag: <body onload="checkCookie()"> 
*/
